package com.contact;

import java.net.URLEncoder;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;

import com.matang.R;
import com.pyq.PyqMainFragment;
import com.pyq.SlectResultActivity;

public class WebviewActivity extends BaseActivity {

	private WebView webview;
	private String title;
	private String text;
	static final String mimeType = "text/html";
	static final String encoding = "UTF-8";
	

	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);

		setContentView(R.layout.webview);
		webview = (WebView) findViewById(R.id.webview);

		if (getIntent() != null) {
			title = getIntent().getStringExtra("title");
			text = getIntent().getStringExtra("text");
		}
		
		initTitle();

		localHtmlZh();
	}
public void initPaneData() {
		findViews();
		header.headRightTv.setBackgroundResource(R.drawable.take_camera);
		
		header.headTitleTv.setText("马聊团队");
		header.headLeftTv.setVisibility(View.VISIBLE);
		header.headRightTv.setVisibility(View.GONE);
		//header.headRightTv.setText("添加");
		header.headRightTv.setOnClickListener(new OnClickListener() {
			
		
			public void onClick(View view) {
				Intent intent = new Intent();
				intent.setClass(getApplicationContext(), SlectResultActivity.class);
				startActivity(intent);
				
			}
		});
		header.headLeftTv.setOnClickListener(new OnClickListener() {
			
	
			public void onClick(View arg0) {
			finish();
			}
		});
	

	}


	/**
	 * 中文显示
	 */
	private void localHtmlZh() {
		try {
			// utf-8编码处理(在SDK1.5模拟器和真实设备上都将出现乱码,SDK1.6上能正常显示)
			// MyWebView.loadData(data, mimeType, encoding);
			// 对数据进行编码处理(SDK1.5版本)
			webview.loadData(URLEncoder.encode(text, encoding), mimeType,
					encoding);
			webview.loadDataWithBaseURL("", text, mimeType, encoding, null);
//			webview.getSettings().setDefaultTextEncodingName("GB2312");
//			webview.loadData(text, "text/html", "GB2312");
			// MyWebView.loadDataWithBaseURL(null, data, mimeType, encoding,
			// null);

		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	/**
	 * 初始化title
	 */
	private void initTitle() {
		initPaneData();
	}

	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub
		this.finish();
		// overridePendingTransition(R.anim.in_from_right, R.anim.out_to_right);
	}

}
